import store from '@/store';
import { deviceEnquire, DEVICE_TYPE } from '@/utils/device';

const AppDeviceEnquire = {
  mounted() {
    deviceEnquire((deviceType) => {
      switch (deviceType) {
        case DEVICE_TYPE.DESKTOP:
          store.dispatch('user/setDeviceType', 'desktop');
          break;
        case DEVICE_TYPE.TABLET:
          store.dispatch('user/setDeviceType', 'tablet');
          break;
        case DEVICE_TYPE.MOBILE:
          store.dispatch('user/setDeviceType', 'mobile');
          break;
        default:
          store.dispatch('user/setDeviceType', 'desktop');
          break;
      }
    });
  }
};

export { AppDeviceEnquire };
